Reading OPUS files

source

This code is modified from the original OPUSreader2 documentation vignettes/opusreader2_introduction.Rmd by Philip Baumann and Thomas Knecht. It reads OPUS binary files and extracts metadata and absorbance data, which can then be plotted.

Plots & Metadata

The main function, read_opus(), reads one or more OPUS files and returns a nested list of class list_opusreader2. Each list contains both the spectral data and metadata for each file. The dsn argument is the data source name. It can be a character vector of folder paths (to read files recursively) or specific OPUS file paths. Start by testing the read_opus function on your corrected spectra folder, and saving the output of the first file.

#load opusreader2 from github.com/spectral-cockpit
library(opusreader2)

#save the data from your corrected files as 'data_test'
data_test <- read_opus(dsn = corr_spectra)
#check the names of the list
names(data_test)
>  [1] "pot001_13C_wheat_wk0_soil_241209.0"   
>  [2] "pot012_13C_soy_wk10_soil_241209.0"    
>  [3] "pot028_13C_wheat_wk0_soil_241205.0"   
>  [4] "pot028_13C_wheat_wk0_soil_241209.0"   
>  [5] "pot029_13C_wheat_wk10_soil_241209.0"  
>  [6] "pot032_13C_wheat_wk0_root_241210.0"   
>  [7] "pot032_13C_wheat_wk0_soil_241209.0"   
>  [8] "pot047_13C_rice_wk0_root_241210.0"    
>  [9] "pot050_13C_soy_wk0_root_241210.0"     
> [10] "pot050_13C_soy_wk0_soil_241205.0"     
> [11] "pot050_13C_soy_wk0_soil_241209.0"     
> [12] "pot053_13C_wheat_wk10_root_241210.0"  
> [13] "pot053_13C_wheat_wk10_soil_241209.0"  
> [14] "pot053_13C_wheat_wk10_soil_241209a.0" 
> [15] "pot055_13C_rice_wk10_root_241205.0"   
> [16] "pot055_13C_rice_wk10_root_241210.0"   
> [17] "pot055_13C_rice_wk10_soil_241205.0"   
> [18] "pot055_13C_rice_wk10_soil_241209.0"   
> [19] "pot062_13C_soy_wk0_root_241205.0"     
> [20] "pot062_13C_soy_wk0_root_241210.0"     
> [21] "pot062_13C_soy_wk0_soil_241205.0"     
> [22] "pot062_13C_soy_wk0_soil_241209.0"     
> [23] "pot072_12C_noPlant_wk10_soil_241210.0"
> [24] "pot079_13C_rice_wk0_root_241210.0"    
> [25] "pot079_13C_rice_wk0_soil_241205.0"    
> [26] "pot079_13C_rice_wk0_soil_241209.0"    
> [27] "pot080_13C_soy_wk10_root_241205.0"    
> [28] "pot080_13C_soy_wk10_soil_241205.0"    
> [29] "pot080_13C_soy_wk10_soil_241209.0"    
> [30] "pot087_13C_rice_wk10_soil_241205.0"   
> [31] "pot087_13C_rice_wk10_soil_241209.0"   
> [32] "pot094_13C_soy_wk10_root_241205.0"    
> [33] "pot094_13C_soy_wk10_root_241210.0"    
> [34] "pot094_13C_soy_wk10_soil_241205.0"    
> [35] "pot094_13C_soy_wk10_soil_241209.0"    
> [36] "pot103_13C_rice_wk0_root_241209.0"    
> [37] "pot103_13C_rice_wk0_root_241210.0"    
> [38] "pot103_13C_rice_wk0_soil_241205.0"    
> [39] "pot119_13C_rice_wk10_soil_241205.0"   
> [40] "pot119_13C_rice_wk10_soil_241209.0"
# define 'meas_1' as the first element of the 'data_test' list
meas_1 <- data_test[[1]]

Helper Functions

Function to extract single-channel spectral data from OPUS files and convert it to absorbance.

ab = -log10(sample/ref)

I’m a bit unsure about this because I already ran a background correction in the OPUS software… I may try running this with raw data later. The DPT files in “Reading DPT files” section below are unaltered from the OPUS software export.

# Helper function to get spectral data from OPUS file data
getSpectralData <- function(data) {
  # First try to find processed absorbance data
  ab_data <- data$ab
  
  if (!is.null(ab_data) &&
        !is.null(ab_data$wavenumbers) && !is.null(ab_data$data) &&
        is.numeric(ab_data$wavenumbers) && is.numeric(ab_data$data) &&
        length(ab_data$wavenumbers) == length(ab_data$data) &&
        all(is.finite(ab_data$wavenumbers)) && all(is.finite(ab_data$data))) {
    return(list(wavenumbers = ab_data$wavenumbers, data = ab_data$data, type = "processed"))
  }
  
  # Try to calculate absorbance from single-channel data
  sample_data <- data$sc_sample
  ref_data <- data$sc_ref
  
  if (!is.null(sample_data) && !is.null(ref_data) &&
      !is.null(sample_data$wavenumbers) && !is.null(sample_data$data) &&
      !is.null(ref_data$wavenumbers) && !is.null(ref_data$data) &&
      is.numeric(sample_data$wavenumbers) && is.numeric(sample_data$data) &&
      is.numeric(ref_data$wavenumbers) && is.numeric(ref_data$data)) {
    
    # Find common wavenumber range
    sample_wn <- as.vector(sample_data$wavenumbers)
    sample_int <- as.vector(sample_data$data)
    ref_wn <- as.vector(ref_data$wavenumbers)
    ref_int <- as.vector(ref_data$data)
    
    # Find overlapping wavenumber range
    min_wn <- max(min(sample_wn), min(ref_wn))
    max_wn <- min(max(sample_wn), max(ref_wn))
    
    # Filter data to common range
    sample_mask <- sample_wn >= min_wn & sample_wn <= max_wn
    ref_mask <- ref_wn >= min_wn & ref_wn <= max_wn
    
    sample_wn_filtered <- sample_wn[sample_mask]
    sample_int_filtered <- sample_int[sample_mask]
    ref_wn_filtered <- ref_wn[ref_mask]
    ref_int_filtered <- ref_int[ref_mask]
    
    # Interpolate reference to sample wavenumbers if needed
    if (length(sample_wn_filtered) != length(ref_wn_filtered) || 
        !all(abs(sample_wn_filtered - ref_wn_filtered) < 0.1)) {
      ref_int_interp <- approx(ref_wn_filtered, ref_int_filtered, 
                              sample_wn_filtered, rule = 2)$y
    } else {
      ref_int_interp <- ref_int_filtered
    }
    
    # Calculate absorbance: A = -log10(Sample/Reference)
    ratio <- sample_int_filtered / (ref_int_interp + 1e-10)
    absorbance <- -log10(pmax(ratio, 1e-10))
    
    # Remove infinite or NaN values
    valid_idx <- is.finite(absorbance) & is.finite(sample_wn_filtered)
    
    if (sum(valid_idx) > 10) {
      return(list(
        wavenumbers = sample_wn_filtered[valid_idx], 
        data = absorbance[valid_idx], 
        type = "calculated"
      ))
    }
  }
  
  return(NULL)  # No valid spectral data found
}

Next I defined a function, plotSpectrum, to plot the spectral data from a single sample (meas_1)

# data is a list containing OPUS file data, including absorbance and metadata.

plotSpectrum <- function(data) { # nolint: object_name_linter.
  spectral_data <- getSpectralData(data)
  
  if (!is.null(spectral_data)) {
    ylabel <- if (spectral_data$type == "calculated") "Absorbance (calculated)" else "Absorbance"
    title_prefix <- if (spectral_data$type == "calculated") "Calculated absorbance: " else ""
    
    plot(
      spectral_data$wavenumbers, spectral_data$data, type = "l",
      xlab = "Wavenumber (cm⁻¹)", ylab = ylabel,
      main = paste0(title_prefix, data$basic_metadata$dsn_filename),
      xlim = rev(range(spectral_data$wavenumbers))
    )
  } else {
    cat("No valid spectral data found in this file.\n")
    cat("Available data blocks:", paste(names(data), collapse = ", "), "\n")
  }
}
plotSpectrum(meas_1)

I then defined the metadataTable function, to extract and display the a subset of the metadata stored in the data extracted by ‘read_opus’ in a table format.

To view all the available data categories, run ‘names(meas_1)’ in the console. To view the parameters within these categories use str(meas_1$category_name) where ‘category_name’ is ‘basic_metadata’, ‘optics’, etc.

Metadata table (folder)

for (i in seq_along(data_test)) {
  cat("#### Spectrum", i, ":", names(data_test)[i], "\n\n")
  data_i <- data_test[[i]]
  print(metadataTable(data_i))
}
> #### Spectrum 1 : pot001_13C_wheat_wk0_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot001_13C_wheat_wk0_soil_241209.0 |
> |Timestamp           |2025-10-07 20:03:28 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |2                                  |
> |Sample Scans        |64                                 |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |103.822998046875                   |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 2 : pot012_13C_soy_wk10_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot012_13C_soy_wk10_soil_241209.0 |
> |Timestamp           |2025-10-07 20:03:37 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |2                                 |
> |Sample Scans        |64                                |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |103.823974609375                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 3 : pot028_13C_wheat_wk0_soil_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot028_13C_wheat_wk0_soil_241205.0 |
> |Timestamp           |2025-10-07 19:27:39 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |4                                  |
> |Sample Scans        |64                                 |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |58.22998046875                     |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 4 : pot028_13C_wheat_wk0_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot028_13C_wheat_wk0_soil_241209.0 |
> |Timestamp           |2025-10-07 20:03:42 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |2                                  |
> |Sample Scans        |64                                 |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |103.818969726562                   |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 5 : pot029_13C_wheat_wk10_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                               |
> |:-------------------|:-----------------------------------|
> |File Name           |pot029_13C_wheat_wk10_soil_241209.0 |
> |Timestamp           |2025-10-07 20:03:47 GMT-7           |
> |Max Y               |NA                                  |
> |Min Y               |NA                                  |
> |Aperture Setting    |6 mm                                |
> |Scanner Velocity    |10.0S                               |
> |Result Spectrum     |ATR                                 |
> |Resolution          |2                                   |
> |Sample Scans        |64                                  |
> |End Frequency       |400                                 |
> |Start Frequency     |4000                                |
> |Duration            |103.821960449219                    |
> |Experiment (method) |Base_soils_method_SSC.xpm           |
> #### Spectrum 6 : pot032_13C_wheat_wk0_root_241210.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot032_13C_wheat_wk0_root_241210.0 |
> |Timestamp           |2025-10-07 20:20:52 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |2                                  |
> |Sample Scans        |128                                |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |207.708984375                      |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 7 : pot032_13C_wheat_wk0_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot032_13C_wheat_wk0_soil_241209.0 |
> |Timestamp           |2025-10-07 20:03:53 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |2                                  |
> |Sample Scans        |64                                 |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |103.820983886719                   |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 8 : pot047_13C_rice_wk0_root_241210.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot047_13C_rice_wk0_root_241210.0 |
> |Timestamp           |2025-10-07 20:21:08 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |2                                 |
> |Sample Scans        |128                               |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |207.707885742188                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 9 : pot050_13C_soy_wk0_root_241210.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                            |
> |:-------------------|:--------------------------------|
> |File Name           |pot050_13C_soy_wk0_root_241210.0 |
> |Timestamp           |2025-10-07 20:21:14 GMT-7        |
> |Max Y               |NA                               |
> |Min Y               |NA                               |
> |Aperture Setting    |6 mm                             |
> |Scanner Velocity    |10.0S                            |
> |Result Spectrum     |ATR                              |
> |Resolution          |2                                |
> |Sample Scans        |128                              |
> |End Frequency       |400                              |
> |Start Frequency     |4000                             |
> |Duration            |207.7109375                      |
> |Experiment (method) |Base_soils_method_SSC.xpm        |
> #### Spectrum 10 : pot050_13C_soy_wk0_soil_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                            |
> |:-------------------|:--------------------------------|
> |File Name           |pot050_13C_soy_wk0_soil_241205.0 |
> |Timestamp           |2025-10-07 19:25:46 GMT-7        |
> |Max Y               |NA                               |
> |Min Y               |NA                               |
> |Aperture Setting    |6 mm                             |
> |Scanner Velocity    |10.0S                            |
> |Result Spectrum     |ATR                              |
> |Resolution          |4                                |
> |Sample Scans        |64                               |
> |End Frequency       |400                              |
> |Start Frequency     |4000                             |
> |Duration            |58.22998046875                   |
> |Experiment (method) |Base_soils_method_SSC.xpm        |
> #### Spectrum 11 : pot050_13C_soy_wk0_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                            |
> |:-------------------|:--------------------------------|
> |File Name           |pot050_13C_soy_wk0_soil_241209.0 |
> |Timestamp           |2025-10-07 20:03:59 GMT-7        |
> |Max Y               |NA                               |
> |Min Y               |NA                               |
> |Aperture Setting    |6 mm                             |
> |Scanner Velocity    |10.0S                            |
> |Result Spectrum     |ATR                              |
> |Resolution          |2                                |
> |Sample Scans        |64                               |
> |End Frequency       |400                              |
> |Start Frequency     |4000                             |
> |Duration            |103.822998046875                 |
> |Experiment (method) |Base_soils_method_SSC.xpm        |
> #### Spectrum 12 : pot053_13C_wheat_wk10_root_241210.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                               |
> |:-------------------|:-----------------------------------|
> |File Name           |pot053_13C_wheat_wk10_root_241210.0 |
> |Timestamp           |2025-10-07 20:21:20 GMT-7           |
> |Max Y               |NA                                  |
> |Min Y               |NA                                  |
> |Aperture Setting    |6 mm                                |
> |Scanner Velocity    |10.0S                               |
> |Result Spectrum     |ATR                                 |
> |Resolution          |2                                   |
> |Sample Scans        |128                                 |
> |End Frequency       |400                                 |
> |Start Frequency     |4000                                |
> |Duration            |207.7109375                         |
> |Experiment (method) |Base_soils_method_SSC.xpm           |
> #### Spectrum 13 : pot053_13C_wheat_wk10_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                               |
> |:-------------------|:-----------------------------------|
> |File Name           |pot053_13C_wheat_wk10_soil_241209.0 |
> |Timestamp           |2025-10-07 20:04:07 GMT-7           |
> |Max Y               |NA                                  |
> |Min Y               |NA                                  |
> |Aperture Setting    |6 mm                                |
> |Scanner Velocity    |10.0S                               |
> |Result Spectrum     |ATR                                 |
> |Resolution          |2                                   |
> |Sample Scans        |64                                  |
> |End Frequency       |400                                 |
> |Start Frequency     |4000                                |
> |Duration            |103.825988769531                    |
> |Experiment (method) |Base_soils_method_SSC.xpm           |
> #### Spectrum 14 : pot053_13C_wheat_wk10_soil_241209a.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                                |
> |:-------------------|:------------------------------------|
> |File Name           |pot053_13C_wheat_wk10_soil_241209a.0 |
> |Timestamp           |2025-10-07 20:04:12 GMT-7            |
> |Max Y               |NA                                   |
> |Min Y               |NA                                   |
> |Aperture Setting    |6 mm                                 |
> |Scanner Velocity    |10.0S                                |
> |Result Spectrum     |ATR                                  |
> |Resolution          |2                                    |
> |Sample Scans        |64                                   |
> |End Frequency       |400                                  |
> |Start Frequency     |4000                                 |
> |Duration            |103.820983886719                     |
> |Experiment (method) |Base_soils_method_SSC.xpm            |
> #### Spectrum 15 : pot055_13C_rice_wk10_root_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot055_13C_rice_wk10_root_241205.0 |
> |Timestamp           |2025-10-07 19:20:22 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |4                                  |
> |Sample Scans        |64                                 |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |58.2289733886719                   |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 16 : pot055_13C_rice_wk10_root_241210.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot055_13C_rice_wk10_root_241210.0 |
> |Timestamp           |2025-10-07 20:21:24 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |2                                  |
> |Sample Scans        |128                                |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |207.713989257812                   |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 17 : pot055_13C_rice_wk10_soil_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot055_13C_rice_wk10_soil_241205.0 |
> |Timestamp           |2025-10-07 19:22:56 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |4                                  |
> |Sample Scans        |64                                 |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |58.2289733886719                   |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 18 : pot055_13C_rice_wk10_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot055_13C_rice_wk10_soil_241209.0 |
> |Timestamp           |2025-10-07 20:04:17 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |2                                  |
> |Sample Scans        |64                                 |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |103.821960449219                   |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 19 : pot062_13C_soy_wk0_root_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                            |
> |:-------------------|:--------------------------------|
> |File Name           |pot062_13C_soy_wk0_root_241205.0 |
> |Timestamp           |2025-10-07 19:16:32 GMT-7        |
> |Max Y               |NA                               |
> |Min Y               |NA                               |
> |Aperture Setting    |6 mm                             |
> |Scanner Velocity    |10.0S                            |
> |Result Spectrum     |ATR                              |
> |Resolution          |4                                |
> |Sample Scans        |64                               |
> |End Frequency       |400                              |
> |Start Frequency     |4000                             |
> |Duration            |58.2289733886719                 |
> |Experiment (method) |Base_soils_method_SSC.xpm        |
> #### Spectrum 20 : pot062_13C_soy_wk0_root_241210.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                            |
> |:-------------------|:--------------------------------|
> |File Name           |pot062_13C_soy_wk0_root_241210.0 |
> |Timestamp           |2025-10-07 20:21:29 GMT-7        |
> |Max Y               |NA                               |
> |Min Y               |NA                               |
> |Aperture Setting    |6 mm                             |
> |Scanner Velocity    |10.0S                            |
> |Result Spectrum     |ATR                              |
> |Resolution          |2                                |
> |Sample Scans        |128                              |
> |End Frequency       |400                              |
> |Start Frequency     |4000                             |
> |Duration            |207.7099609375                   |
> |Experiment (method) |Base_soils_method_SSC.xpm        |
> #### Spectrum 21 : pot062_13C_soy_wk0_soil_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                            |
> |:-------------------|:--------------------------------|
> |File Name           |pot062_13C_soy_wk0_soil_241205.0 |
> |Timestamp           |2025-10-07 19:26:21 GMT-7        |
> |Max Y               |NA                               |
> |Min Y               |NA                               |
> |Aperture Setting    |6 mm                             |
> |Scanner Velocity    |10.0S                            |
> |Result Spectrum     |ATR                              |
> |Resolution          |4                                |
> |Sample Scans        |64                               |
> |End Frequency       |400                              |
> |Start Frequency     |4000                             |
> |Duration            |58.2289733886719                 |
> |Experiment (method) |Base_soils_method_SSC.xpm        |
> #### Spectrum 22 : pot062_13C_soy_wk0_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                            |
> |:-------------------|:--------------------------------|
> |File Name           |pot062_13C_soy_wk0_soil_241209.0 |
> |Timestamp           |2025-10-07 20:04:54 GMT-7        |
> |Max Y               |NA                               |
> |Min Y               |NA                               |
> |Aperture Setting    |6 mm                             |
> |Scanner Velocity    |10.0S                            |
> |Result Spectrum     |ATR                              |
> |Resolution          |2                                |
> |Sample Scans        |64                               |
> |End Frequency       |400                              |
> |Start Frequency     |4000                             |
> |Duration            |103.818969726562                 |
> |Experiment (method) |Base_soils_method_SSC.xpm        |
> #### Spectrum 23 : pot072_12C_noPlant_wk10_soil_241210.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                                 |
> |:-------------------|:-------------------------------------|
> |File Name           |pot072_12C_noPlant_wk10_soil_241210.0 |
> |Timestamp           |2025-10-07 20:21:34 GMT-7             |
> |Max Y               |NA                                    |
> |Min Y               |NA                                    |
> |Aperture Setting    |6 mm                                  |
> |Scanner Velocity    |10.0S                                 |
> |Result Spectrum     |ATR                                   |
> |Resolution          |4                                     |
> |Sample Scans        |256                                   |
> |End Frequency       |400                                   |
> |Start Frequency     |4000                                  |
> |Duration            |233.10595703125                       |
> |Experiment (method) |Base_soils_method_SSC.xpm             |
> #### Spectrum 24 : pot079_13C_rice_wk0_root_241210.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot079_13C_rice_wk0_root_241210.0 |
> |Timestamp           |2025-10-07 20:21:40 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |2                                 |
> |Sample Scans        |128                               |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |207.7109375                       |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 25 : pot079_13C_rice_wk0_soil_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot079_13C_rice_wk0_soil_241205.0 |
> |Timestamp           |2025-10-07 19:23:44 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |4                                 |
> |Sample Scans        |64                                |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |58.2289733886719                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 26 : pot079_13C_rice_wk0_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot079_13C_rice_wk0_soil_241209.0 |
> |Timestamp           |2025-10-07 20:04:22 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |2                                 |
> |Sample Scans        |64                                |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |103.820983886719                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 27 : pot080_13C_soy_wk10_root_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot080_13C_soy_wk10_root_241205.0 |
> |Timestamp           |2025-10-07 19:21:18 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |4                                 |
> |Sample Scans        |64                                |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |58.2309875488281                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 28 : pot080_13C_soy_wk10_soil_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot080_13C_soy_wk10_soil_241205.0 |
> |Timestamp           |2025-10-07 19:28:19 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |4                                 |
> |Sample Scans        |64                                |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |22.7099914550781                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 29 : pot080_13C_soy_wk10_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot080_13C_soy_wk10_soil_241209.0 |
> |Timestamp           |2025-10-07 20:04:26 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |2                                 |
> |Sample Scans        |64                                |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |103.818969726562                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 30 : pot087_13C_rice_wk10_soil_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot087_13C_rice_wk10_soil_241205.0 |
> |Timestamp           |2025-10-07 19:24:21 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |4                                  |
> |Sample Scans        |64                                 |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |58.22998046875                     |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 31 : pot087_13C_rice_wk10_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot087_13C_rice_wk10_soil_241209.0 |
> |Timestamp           |2025-10-07 20:04:31 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |2                                  |
> |Sample Scans        |64                                 |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |103.821960449219                   |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 32 : pot094_13C_soy_wk10_root_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot094_13C_soy_wk10_root_241205.0 |
> |Timestamp           |2025-10-07 19:19:21 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |4                                 |
> |Sample Scans        |64                                |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |58.2289733886719                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 33 : pot094_13C_soy_wk10_root_241210.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot094_13C_soy_wk10_root_241210.0 |
> |Timestamp           |2025-10-07 20:21:44 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |2                                 |
> |Sample Scans        |128                               |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |207.706909179688                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 34 : pot094_13C_soy_wk10_soil_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot094_13C_soy_wk10_soil_241205.0 |
> |Timestamp           |2025-10-07 19:27:00 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |4                                 |
> |Sample Scans        |64                                |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |58.22998046875                    |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 35 : pot094_13C_soy_wk10_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot094_13C_soy_wk10_soil_241209.0 |
> |Timestamp           |2025-10-07 20:04:35 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |2                                 |
> |Sample Scans        |64                                |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |103.819946289062                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 36 : pot103_13C_rice_wk0_root_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot103_13C_rice_wk0_root_241209.0 |
> |Timestamp           |2025-10-07 20:04:39 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |2                                 |
> |Sample Scans        |128                               |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |207.707885742188                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 37 : pot103_13C_rice_wk0_root_241210.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot103_13C_rice_wk0_root_241210.0 |
> |Timestamp           |2025-10-07 20:21:49 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |2                                 |
> |Sample Scans        |64                                |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |103.820983886719                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 38 : pot103_13C_rice_wk0_soil_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                             |
> |:-------------------|:---------------------------------|
> |File Name           |pot103_13C_rice_wk0_soil_241205.0 |
> |Timestamp           |2025-10-07 19:24:58 GMT-7         |
> |Max Y               |NA                                |
> |Min Y               |NA                                |
> |Aperture Setting    |6 mm                              |
> |Scanner Velocity    |10.0S                             |
> |Result Spectrum     |ATR                               |
> |Resolution          |4                                 |
> |Sample Scans        |64                                |
> |End Frequency       |400                               |
> |Start Frequency     |4000                              |
> |Duration            |58.2289733886719                  |
> |Experiment (method) |Base_soils_method_SSC.xpm         |
> #### Spectrum 39 : pot119_13C_rice_wk10_soil_241205.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot119_13C_rice_wk10_soil_241205.0 |
> |Timestamp           |2025-10-07 19:22:09 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |4                                  |
> |Sample Scans        |64                                 |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |58.2279968261719                   |
> |Experiment (method) |Base_soils_method_SSC.xpm          |
> #### Spectrum 40 : pot119_13C_rice_wk10_soil_241209.0 
> 
> 
> 
> Table: Metadata
> 
> |Parameter           |Value                              |
> |:-------------------|:----------------------------------|
> |File Name           |pot119_13C_rice_wk10_soil_241209.0 |
> |Timestamp           |2025-10-07 20:04:44 GMT-7          |
> |Max Y               |NA                                 |
> |Min Y               |NA                                 |
> |Aperture Setting    |6 mm                               |
> |Scanner Velocity    |10.0S                              |
> |Result Spectrum     |ATR                                |
> |Resolution          |2                                  |
> |Sample Scans        |64                                 |
> |End Frequency       |400                                |
> |Start Frequency     |4000                               |
> |Duration            |103.821960449219                   |
> |Experiment (method) |Base_soils_method_SSC.xpm          |

The plotMetadata function combines the plot and table for a single spectrum.

plotMetadata <- function(data) { # nolint: object_name_linter.
  plotSpectrum(data)
  metadataTable(data)
}
plotMetadata(meas_1)

Metadata
Parameter Value
File Name pot001_13C_wheat_wk0_soil_241209.0
Timestamp 2025-10-07 20:03:28 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.822998046875
Experiment (method) Base_soils_method_SSC.xpm

Combined plot and table (folder)

The following for loop runs plotMetadata on each spectrum in the data_test list, which contains all the spectra in the folder. It will plot each spectrum and print its metadata below. Clearly the data varies in quality, with different resolution and sample scans parameters.

for (i in seq_along(data_test)) {
  cat("#### Spectrum", i, ":", names(data_test)[i], "\n\n")
  data_i <- data_test[[i]]
  
  # Check if we can get valid spectral data
  spectral_data <- getSpectralData(data_i)
  
  if (!is.null(spectral_data)) {
    plotSpectrum(data_i)
    print(metadataTable(data_i))
  } else {
    cat("Data not valid or missing for this spectrum.\n")
    cat("Available data blocks:", paste(names(data_i), collapse = ", "), "\n")
  }
}

Spectrum 1 : pot001_13C_wheat_wk0_soil_241209.0

Metadata
Parameter Value
File Name pot001_13C_wheat_wk0_soil_241209.0
Timestamp 2025-10-07 20:03:28 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.822998046875
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 2 : pot012_13C_soy_wk10_soil_241209.0

Metadata
Parameter Value
File Name pot012_13C_soy_wk10_soil_241209.0
Timestamp 2025-10-07 20:03:37 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.823974609375
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 3 : pot028_13C_wheat_wk0_soil_241205.0

Metadata
Parameter Value
File Name pot028_13C_wheat_wk0_soil_241205.0
Timestamp 2025-10-07 19:27:39 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.22998046875
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 4 : pot028_13C_wheat_wk0_soil_241209.0

Metadata
Parameter Value
File Name pot028_13C_wheat_wk0_soil_241209.0
Timestamp 2025-10-07 20:03:42 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.818969726562
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 5 : pot029_13C_wheat_wk10_soil_241209.0

Metadata
Parameter Value
File Name pot029_13C_wheat_wk10_soil_241209.0
Timestamp 2025-10-07 20:03:47 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.821960449219
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 6 : pot032_13C_wheat_wk0_root_241210.0

Metadata
Parameter Value
File Name pot032_13C_wheat_wk0_root_241210.0
Timestamp 2025-10-07 20:20:52 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 128
End Frequency 400
Start Frequency 4000
Duration 207.708984375
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 7 : pot032_13C_wheat_wk0_soil_241209.0

Metadata
Parameter Value
File Name pot032_13C_wheat_wk0_soil_241209.0
Timestamp 2025-10-07 20:03:53 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.820983886719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 8 : pot047_13C_rice_wk0_root_241210.0

Metadata
Parameter Value
File Name pot047_13C_rice_wk0_root_241210.0
Timestamp 2025-10-07 20:21:08 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 128
End Frequency 400
Start Frequency 4000
Duration 207.707885742188
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 9 : pot050_13C_soy_wk0_root_241210.0

Metadata
Parameter Value
File Name pot050_13C_soy_wk0_root_241210.0
Timestamp 2025-10-07 20:21:14 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 128
End Frequency 400
Start Frequency 4000
Duration 207.7109375
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 10 : pot050_13C_soy_wk0_soil_241205.0

Metadata
Parameter Value
File Name pot050_13C_soy_wk0_soil_241205.0
Timestamp 2025-10-07 19:25:46 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.22998046875
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 11 : pot050_13C_soy_wk0_soil_241209.0

Metadata
Parameter Value
File Name pot050_13C_soy_wk0_soil_241209.0
Timestamp 2025-10-07 20:03:59 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.822998046875
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 12 : pot053_13C_wheat_wk10_root_241210.0

Metadata
Parameter Value
File Name pot053_13C_wheat_wk10_root_241210.0
Timestamp 2025-10-07 20:21:20 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 128
End Frequency 400
Start Frequency 4000
Duration 207.7109375
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 13 : pot053_13C_wheat_wk10_soil_241209.0

Metadata
Parameter Value
File Name pot053_13C_wheat_wk10_soil_241209.0
Timestamp 2025-10-07 20:04:07 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.825988769531
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 14 : pot053_13C_wheat_wk10_soil_241209a.0

Metadata
Parameter Value
File Name pot053_13C_wheat_wk10_soil_241209a.0
Timestamp 2025-10-07 20:04:12 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.820983886719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 15 : pot055_13C_rice_wk10_root_241205.0

Metadata
Parameter Value
File Name pot055_13C_rice_wk10_root_241205.0
Timestamp 2025-10-07 19:20:22 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.2289733886719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 16 : pot055_13C_rice_wk10_root_241210.0

Metadata
Parameter Value
File Name pot055_13C_rice_wk10_root_241210.0
Timestamp 2025-10-07 20:21:24 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 128
End Frequency 400
Start Frequency 4000
Duration 207.713989257812
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 17 : pot055_13C_rice_wk10_soil_241205.0

Metadata
Parameter Value
File Name pot055_13C_rice_wk10_soil_241205.0
Timestamp 2025-10-07 19:22:56 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.2289733886719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 18 : pot055_13C_rice_wk10_soil_241209.0

Metadata
Parameter Value
File Name pot055_13C_rice_wk10_soil_241209.0
Timestamp 2025-10-07 20:04:17 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.821960449219
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 19 : pot062_13C_soy_wk0_root_241205.0

Metadata
Parameter Value
File Name pot062_13C_soy_wk0_root_241205.0
Timestamp 2025-10-07 19:16:32 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.2289733886719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 20 : pot062_13C_soy_wk0_root_241210.0

Metadata
Parameter Value
File Name pot062_13C_soy_wk0_root_241210.0
Timestamp 2025-10-07 20:21:29 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 128
End Frequency 400
Start Frequency 4000
Duration 207.7099609375
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 21 : pot062_13C_soy_wk0_soil_241205.0

Metadata
Parameter Value
File Name pot062_13C_soy_wk0_soil_241205.0
Timestamp 2025-10-07 19:26:21 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.2289733886719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 22 : pot062_13C_soy_wk0_soil_241209.0

Metadata
Parameter Value
File Name pot062_13C_soy_wk0_soil_241209.0
Timestamp 2025-10-07 20:04:54 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.818969726562
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 23 : pot072_12C_noPlant_wk10_soil_241210.0

Metadata
Parameter Value
File Name pot072_12C_noPlant_wk10_soil_241210.0
Timestamp 2025-10-07 20:21:34 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 256
End Frequency 400
Start Frequency 4000
Duration 233.10595703125
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 24 : pot079_13C_rice_wk0_root_241210.0

Metadata
Parameter Value
File Name pot079_13C_rice_wk0_root_241210.0
Timestamp 2025-10-07 20:21:40 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 128
End Frequency 400
Start Frequency 4000
Duration 207.7109375
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 25 : pot079_13C_rice_wk0_soil_241205.0

Metadata
Parameter Value
File Name pot079_13C_rice_wk0_soil_241205.0
Timestamp 2025-10-07 19:23:44 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.2289733886719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 26 : pot079_13C_rice_wk0_soil_241209.0

Metadata
Parameter Value
File Name pot079_13C_rice_wk0_soil_241209.0
Timestamp 2025-10-07 20:04:22 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.820983886719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 27 : pot080_13C_soy_wk10_root_241205.0

Metadata
Parameter Value
File Name pot080_13C_soy_wk10_root_241205.0
Timestamp 2025-10-07 19:21:18 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.2309875488281
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 28 : pot080_13C_soy_wk10_soil_241205.0

Metadata
Parameter Value
File Name pot080_13C_soy_wk10_soil_241205.0
Timestamp 2025-10-07 19:28:19 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 22.7099914550781
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 29 : pot080_13C_soy_wk10_soil_241209.0

Metadata
Parameter Value
File Name pot080_13C_soy_wk10_soil_241209.0
Timestamp 2025-10-07 20:04:26 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.818969726562
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 30 : pot087_13C_rice_wk10_soil_241205.0

Metadata
Parameter Value
File Name pot087_13C_rice_wk10_soil_241205.0
Timestamp 2025-10-07 19:24:21 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.22998046875
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 31 : pot087_13C_rice_wk10_soil_241209.0

Metadata
Parameter Value
File Name pot087_13C_rice_wk10_soil_241209.0
Timestamp 2025-10-07 20:04:31 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.821960449219
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 32 : pot094_13C_soy_wk10_root_241205.0

Metadata
Parameter Value
File Name pot094_13C_soy_wk10_root_241205.0
Timestamp 2025-10-07 19:19:21 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.2289733886719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 33 : pot094_13C_soy_wk10_root_241210.0

Metadata
Parameter Value
File Name pot094_13C_soy_wk10_root_241210.0
Timestamp 2025-10-07 20:21:44 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 128
End Frequency 400
Start Frequency 4000
Duration 207.706909179688
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 34 : pot094_13C_soy_wk10_soil_241205.0

Metadata
Parameter Value
File Name pot094_13C_soy_wk10_soil_241205.0
Timestamp 2025-10-07 19:27:00 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.22998046875
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 35 : pot094_13C_soy_wk10_soil_241209.0

Metadata
Parameter Value
File Name pot094_13C_soy_wk10_soil_241209.0
Timestamp 2025-10-07 20:04:35 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.819946289062
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 36 : pot103_13C_rice_wk0_root_241209.0

Metadata
Parameter Value
File Name pot103_13C_rice_wk0_root_241209.0
Timestamp 2025-10-07 20:04:39 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 128
End Frequency 400
Start Frequency 4000
Duration 207.707885742188
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 37 : pot103_13C_rice_wk0_root_241210.0

Metadata
Parameter Value
File Name pot103_13C_rice_wk0_root_241210.0
Timestamp 2025-10-07 20:21:49 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.820983886719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 38 : pot103_13C_rice_wk0_soil_241205.0

Metadata
Parameter Value
File Name pot103_13C_rice_wk0_soil_241205.0
Timestamp 2025-10-07 19:24:58 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.2289733886719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 39 : pot119_13C_rice_wk10_soil_241205.0

Metadata
Parameter Value
File Name pot119_13C_rice_wk10_soil_241205.0
Timestamp 2025-10-07 19:22:09 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 4
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 58.2279968261719
Experiment (method) Base_soils_method_SSC.xpm

Spectrum 40 : pot119_13C_rice_wk10_soil_241209.0

Metadata
Parameter Value
File Name pot119_13C_rice_wk10_soil_241209.0
Timestamp 2025-10-07 20:04:44 GMT-7
Max Y NA
Min Y NA
Aperture Setting 6 mm
Scanner Velocity 10.0S
Result Spectrum ATR
Resolution 2
Sample Scans 64
End Frequency 400
Start Frequency 4000
Duration 103.821960449219
Experiment (method) Base_soils_method_SSC.xpm

Stacking multiple spectra

Stacking re-runs

This code looks for files with the same sample number and stacks their spectra, to check whether reruns are consistent.

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  echo = TRUE,
  results = "markup",
  include = TRUE
)
library(opusreader2)
library(RColorBrewer)

data_test <- read_opus(dsn = corr_spectra)

# Helper function to get spectral data from OPUS file data
getSpectralData <- function(data) {
  # First try to find processed absorbance data
  ab_data <- data$ab
  
  if (!is.null(ab_data) &&
        !is.null(ab_data$wavenumbers) && !is.null(ab_data$data) &&
        is.numeric(ab_data$wavenumbers) && is.numeric(ab_data$data) &&
        length(ab_data$wavenumbers) == length(ab_data$data) &&
        all(is.finite(ab_data$wavenumbers)) && all(is.finite(ab_data$data))) {
    return(list(wavenumbers = ab_data$wavenumbers, data = ab_data$data, type = "processed"))
  }
  
  # Try to calculate absorbance from single-channel data
  sample_data <- data$sc_sample
  ref_data <- data$sc_ref
  
  if (!is.null(sample_data) && !is.null(ref_data) &&
      !is.null(sample_data$wavenumbers) && !is.null(sample_data$data) &&
      !is.null(ref_data$wavenumbers) && !is.null(ref_data$data) &&
      is.numeric(sample_data$wavenumbers) && is.numeric(sample_data$data) &&
      is.numeric(ref_data$wavenumbers) && is.numeric(ref_data$data)) {
    
    # Find common wavenumber range
    sample_wn <- as.vector(sample_data$wavenumbers)
    sample_int <- as.vector(sample_data$data)
    ref_wn <- as.vector(ref_data$wavenumbers)
    ref_int <- as.vector(ref_data$data)
    
    # Find overlapping wavenumber range
    min_wn <- max(min(sample_wn), min(ref_wn))
    max_wn <- min(max(sample_wn), max(ref_wn))
    
    # Filter data to common range
    sample_mask <- sample_wn >= min_wn & sample_wn <= max_wn
    ref_mask <- ref_wn >= min_wn & ref_wn <= max_wn
    
    sample_wn_filtered <- sample_wn[sample_mask]
    sample_int_filtered <- sample_int[sample_mask]
    ref_wn_filtered <- ref_wn[ref_mask]
    ref_int_filtered <- ref_int[ref_mask]
    
    # Interpolate reference to sample wavenumbers if needed
    if (length(sample_wn_filtered) != length(ref_wn_filtered) || 
        !all(abs(sample_wn_filtered - ref_wn_filtered) < 0.1)) {
      ref_int_interp <- approx(ref_wn_filtered, ref_int_filtered, 
                              sample_wn_filtered, rule = 2)$y
    } else {
      ref_int_interp <- ref_int_filtered
    }
    
    # Calculate absorbance: A = -log10(Sample/Reference)
    ratio <- sample_int_filtered / (ref_int_interp + 1e-10)
    absorbance <- -log10(pmax(ratio, 1e-10))
    
    # Remove infinite or NaN values
    valid_idx <- is.finite(absorbance) & is.finite(sample_wn_filtered)
    
    if (sum(valid_idx) > 10) {
      return(list(
        wavenumbers = sample_wn_filtered[valid_idx], 
        data = absorbance[valid_idx], 
        type = "calculated"
      ))
    }
  }
  
  return(NULL)  # No valid spectral data found
}

# Helper to extract sample number from filename (e.g., "pot094")
extract_sample_number <- function(filename) {
  m <- regexpr("[a-z]{3}[0-9]+", filename)
  if (m[1] != -1) {
    regmatches(filename, m)
  } else {
    NA
  }
}

# Helper to extract sample type (e.g.,"soil", "root")
extract_sample_type <- function(filename) {
  m <- regexpr("soil|root", filename, ignore.case = TRUE)
  if (m[1] != -1) {
    tolower(regmatches(filename, m))
  } else {
    NA
  }
}

# Helper to extract timepoint (e.g., "wk0", "wk40")
extract_timepoint <- function(filename) {
  m <- regexpr("wk[0-9]+", filename, ignore.case = TRUE)
  if (m[1] != -1) {
    tolower(regmatches(filename, m))
  } else {
    NA
  }
}

# Group files by sample number, sample type, and timepoint
sample_numbers <- sapply(names(data_test), extract_sample_number)
sample_types <- sapply(names(data_test), extract_sample_type)
timepoints <- sapply(names(data_test), extract_timepoint)

# Create unique combinations of sample number, sample type, and timepoint
sample_combinations <- paste(sample_numbers, sample_types, timepoints, sep = "_")
unique_combinations <- unique(sample_combinations[!is.na(sample_numbers)
                                                  & !is.na(sample_types)
                                                  & !is.na(timepoints)])

# Plot stacked spectra for each unique combination
library(RColorBrewer)
for (combination in unique_combinations) {
  idx <- which(sample_combinations == combination)
  if (length(idx) > 1) {
    # Extract sample number, type, and timepoint from combination
    parts <- strsplit(combination, "_")[[1]]
    sample_num <- parts[1]
    sample_type <- parts[2]
    timepoint <- parts[3]

    spectra <- data_test[idx]
    colors <- brewer.pal(min(length(spectra), 8), "Set1")
    
    # Get spectral data for all spectra in this combination
    spectral_list <- lapply(spectra, getSpectralData)
    valid_spectra <- !sapply(spectral_list, is.null)
    
    if (!any(valid_spectra)) {
      cat("Skipping", combination, "- no valid spectral data\n")
      next
    }
    
    # Filter to valid spectra only
    spectral_list <- spectral_list[valid_spectra]
    spectra <- spectra[valid_spectra]
    colors <- colors[seq_along(spectral_list)]
    
    # Get ranges for plotting
    all_wavenumbers <- unlist(lapply(spectral_list, function(x) x$wavenumbers))
    all_absorbance <- unlist(lapply(spectral_list, function(x) x$data))
    
    plot(NULL, xlim = rev(range(all_wavenumbers, na.rm = TRUE)),
         ylim = range(all_absorbance, na.rm = TRUE),
         xlab = "Wavenumber (cm⁻¹)", ylab = "Absorbance",
         main = paste("Stacked spectra for", sample_num, "-", sample_type, "-", timepoint),
         bty = "l")
    
    for (i in seq_along(spectral_list)) {
      spec_data <- spectral_list[[i]]
      lines(spec_data$wavenumbers, spec_data$data, col = colors[i], lwd = 2)
    }
    
    legend("topright",
           inset = c(-0.05, -0.02),
           legend = names(spectra),
           col = colors[seq_len(length(spectral_list))],
           lwd = 2,
           xpd = TRUE,
           bty = "n")
  }
}

Stacking by crop & time

This code stacks spectra of the same crop and timepoint.

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  echo = TRUE,
  results = "markup",
  include = TRUE
)
# Helper functions to extract crop and timepoint from filename
extract_crop <- function(filename) {
  m <- regexpr("rice|wheat|soy", filename, ignore.case = TRUE)
  if (m[1] != -1) tolower(regmatches(filename, m)) else NA
}
extract_time <- function(filename) {
  m <- regexpr("wk[0-9]+", filename, ignore.case = TRUE)
  if (m[1] != -1) tolower(regmatches(filename, m)) else NA
}
extract_sample_type <- function(filename) {
  m <- regexpr("root|soil", filename, ignore.case = TRUE)
  if (m[1] != -1) {
    tolower(regmatches(filename, m))
  } else {
    NA
  }
}
# Get crop and time for each file
crops <- sapply(names(data_test), extract_crop)
times <- sapply(names(data_test), extract_time)
types <- sapply(names(data_test), extract_sample_type)

# Unique crop-time combinations
combos <- na.omit(unique(paste(crops, times, types, sep = "_")))

library(RColorBrewer)
for (combo in combos) {
  idx <- which(paste(crops, times, types, sep = "_") == combo)
  if (length(idx) > 1) {
    spectra <- data_test[idx]
    colors <- brewer.pal(min(length(spectra), 8), "Set1")
    
    # Get spectral data for all spectra in this combination
    spectral_list <- lapply(spectra, getSpectralData)
    valid_spectra <- !sapply(spectral_list, is.null)
    
    if (!any(valid_spectra)) {
      cat("Skipping", combo, "- no valid spectral data\n")
      next
    }
    
    # Filter to valid spectra only
    spectral_list <- spectral_list[valid_spectra]
    spectra <- spectra[valid_spectra]
    colors <- colors[seq_along(spectral_list)]
    
    # Get ranges for plotting
    all_wavenumbers <- unlist(lapply(spectral_list, function(x) x$wavenumbers))
    all_absorbance <- unlist(lapply(spectral_list, function(x) x$data))
    
    plot(NULL, xlim = rev(range(all_wavenumbers, na.rm = TRUE)),
         ylim = range(all_absorbance, na.rm = TRUE),
         xlab = "Wavenumber (cm⁻¹)", ylab = "Absorbance",
         main = paste("Stacked spectra for", combo),
         bty = "l")
    
    for (i in seq_along(spectral_list)) {
      spec_data <- spectral_list[[i]]
      lines(spec_data$wavenumbers, spec_data$data, col = colors[i], lwd = 2)
    }
    
    legend("topright",
           inset = c(-0.05, -0.02),
           legend = names(spectra),
           col = colors[seq_len(length(spectral_list))],
           lwd = 2,
           xpd = TRUE,
           bty = "n")
  }
}

Reading DPT files

This code is modified from code by Stephany Soledad Chacon, “Box> Salk Institute Project> Salk Data> FTIR_Intact_decomposition_pots> FTIR_analysis.Rmd”. Using data in the DPT format, we can extrapolate sample attributes from the file names, then normalize and visualize spectra across replicates, crops, and timepoints. The width of the line bounding the spectra represents the range of the data.

Importing FTIR data using readr

Define file path and import multiple files into one data frame

#> Files found in directory:
#>  [1] "pot001_13C_wheat_wk0_soil_241209.0.dpt"   
#>  [2] "pot012_13C_soy_wk10_soil_241209.0.dpt"    
#>  [3] "pot028_13C_wheat_wk0_soil_241205.0.dpt"   
#>  [4] "pot028_13C_wheat_wk0_soil_241209.0.dpt"   
#>  [5] "pot029_13C_wheat_wk10_soil_241209.0.dpt"  
#>  [6] "pot032_13C_wheat_wk0_root_241210.0.dpt"   
#>  [7] "pot032_13C_wheat_wk0_soil_241209.0.dpt"   
#>  [8] "pot047_13C_rice_wk0_root_241210.0.dpt"    
#>  [9] "pot050_13C_soy_wk0_root_241210.0.dpt"     
#> [10] "pot050_13C_soy_wk0_soil_241205.0.dpt"     
#> [11] "pot050_13C_soy_wk0_soil_241209.0.dpt"     
#> [12] "pot053_13C_wheat_wk10_root_241210.0.dpt"  
#> [13] "pot053_13C_wheat_wk10_soil_241209.0.dpt"  
#> [14] "pot053_13C_wheat_wk10_soil_241209a.0.dpt" 
#> [15] "pot055_13C_rice_wk10_root_241205.0.dpt"   
#> [16] "pot055_13C_rice_wk10_root_241210.0.dpt"   
#> [17] "pot055_13C_rice_wk10_soil_241205.0.dpt"   
#> [18] "pot055_13C_rice_wk10_soil_241209.0.dpt"   
#> [19] "pot062_13C_soy_wk0_root_241205.0.dpt"     
#> [20] "pot062_13C_soy_wk0_root_241210.0.dpt"     
#> [21] "pot062_13C_soy_wk0_soil_241205.0.dpt"     
#> [22] "pot062_13C_soy_wk0_soil_241209.0"         
#> [23] "pot072_12C_noPlant_wk10_soil_241210.0.dpt"
#> [24] "pot079_13C_rice_wk0_root_241210.0.dpt"    
#> [25] "pot079_13C_rice_wk0_soil_241205.0.dpt"    
#> [26] "pot079_13C_rice_wk0_soil_241209.0.dpt"    
#> [27] "pot080_13C_soy_wk10_root_241205.0.dpt"    
#> [28] "pot080_13C_soy_wk10_soil_241205.0.dpt"    
#> [29] "pot080_13C_soy_wk10_soil_241209.0.dpt"    
#> [30] "pot087_13C_rice_wk10_soil_241205.0.dpt"   
#> [31] "pot087_13C_rice_wk10_soil_241209.0.dpt"   
#> [32] "pot094_13C_soy_wk10_root_241205.0.dpt"    
#> [33] "pot094_13C_soy_wk10_root_241210.0.dpt"    
#> [34] "pot094_13C_soy_wk10_soil_241205.0.dpt"    
#> [35] "pot094_13C_soy_wk10_soil_241209.0.dpt"    
#> [36] "pot103_13C_rice_wk0_root_241209.0.dpt"    
#> [37] "pot103_13C_rice_wk0_root_241210.0.dpt"    
#> [38] "pot103_13C_rice_wk0_soil_241205.0.dpt"    
#> [39] "pot119_13C_rice_wk10_soil_241205.0.dpt"   
#> [40] "pot119_13C_rice_wk10_soil_241209.0.dpt"
#> Number of .dpt files: 39

Extract sample info from filename

Using the long format dataframe dpt_data format example: pot028_13C_wheat_wk0_soil_241209.0.dpt

#> Column filenames: wavenumber absorbance filename
#> [1] "pot"
#>  [1] "001" "012" "028" "029" "032" "047" "050" "053" "055" "062" "072" "079"
#> [13] "080" "087" "094" "103" "119"
#> [1] 13 12
#> [1] "wheat"   "soy"     "rice"    "noPlant"
#> [1] "wk0"  "wk10"
#> [1] "soil" "root"
#> [1] "241209"  "241205"  "241210"  "241209a"
#> [1] NA
#> # A tibble: 6 × 11
#>   wavenumber absorbance filename      source ID    isotope crop  timepoint type 
#>        <dbl>      <dbl> <chr>         <chr>  <chr>   <dbl> <chr> <chr>     <chr>
#> 1      3999.    0.00261 pot001_13C_w… pot    001        13 wheat wk0       soil 
#> 2      3998.    0.00261 pot001_13C_w… pot    001        13 wheat wk0       soil 
#> 3      3997.    0.00261 pot001_13C_w… pot    001        13 wheat wk0       soil 
#> 4      3997.    0.00261 pot001_13C_w… pot    001        13 wheat wk0       soil 
#> 5      3996.    0.00261 pot001_13C_w… pot    001        13 wheat wk0       soil 
#> 6      3996.    0.00261 pot001_13C_w… pot    001        13 wheat wk0       soil 
#> # ℹ 2 more variables: run_date <chr>, notes <lgl>

Normalize absorbance data

For each file, create a normalized absorbance column (nabs) by dividing each absorbance value by the maximum absorbance for that file.

Plotting by timepoint and type

These plots are of normalized absorbance values. The thickness of the opaque line represents the range of the data. Dotted lines at specific wavenumbers indicate key absorption features of suberin. Lines in black are exclusively assigned to suberin, while gray lines are non-exclusively assigned.

According to Martins et al. 2014:

Major peaks, which can be almost exclusively assigned to suberin, are at 2921 cm-1, 2851 cm-1 and 1737 cm-1. The remaining peaks are simultaneously assigned to the fungal cell wall and either to suberin (1158 cm-1 and 1635 cm-1)…

— Martins, I., Hartmann, D.O., Alves, P.C. et al. Elucidating how the saprophytic fungus Aspergillus nidulans uses the plant polyester suberin as carbon source. BMC Genomics 15, 613 (2014). https://doi.org/10.1186/1471-2164-15-613

1737 = C=O stretch (esters)

Week 0

FALSE [1] "032" "050" "062" "079" "103"
FALSE # A tibble: 41,990 × 12
FALSE # Groups:   filename [10]
FALSE    wavenumber absorbance filename     source ID    isotope crop  timepoint type 
FALSE         <dbl>      <dbl> <chr>        <chr>  <chr>   <dbl> <chr> <chr>     <chr>
FALSE  1      3999.    0.00261 pot001_13C_… pot    001        13 wheat wk0       soil 
FALSE  2      3998.    0.00261 pot001_13C_… pot    001        13 wheat wk0       soil 
FALSE  3      3997.    0.00261 pot001_13C_… pot    001        13 wheat wk0       soil 
FALSE  4      3997.    0.00261 pot001_13C_… pot    001        13 wheat wk0       soil 
FALSE  5      3996.    0.00261 pot001_13C_… pot    001        13 wheat wk0       soil 
FALSE  6      3996.    0.00261 pot001_13C_… pot    001        13 wheat wk0       soil 
FALSE  7      3995.    0.00261 pot001_13C_… pot    001        13 wheat wk0       soil 
FALSE  8      3994.    0.00261 pot001_13C_… pot    001        13 wheat wk0       soil 
FALSE  9      3994.    0.00261 pot001_13C_… pot    001        13 wheat wk0       soil 
FALSE 10      3993.    0.00261 pot001_13C_… pot    001        13 wheat wk0       soil 
FALSE # ℹ 41,980 more rows
FALSE # ℹ 3 more variables: run_date <chr>, notes <lgl>, nabs <dbl>

FALSE [1] "001" "028" "032" "050" "062" "079" "103"

Week 10

#> [1] "053" "055" "080"

#> [1] "012" "029" "053" "055" "072" "080" "087" "094" "119"

Plotting by crop

These plots are of normalized absorbance values. The thickness of the opaque line represents the range of the data. Dotted lines at specific wavenumbers indicate key absorption features of suberin. Lines in black are exclusively assigned to suberin, while gray lines are non-exclusively assigned.

According to Martins et al. 2014:

Major peaks, which can be almost exclusively assigned to suberin, are at 2921 cm-1, 2851 cm-1 and 1737 cm-1. The remaining peaks are simultaneously assigned to the fungal cell wall and either to suberin (1158 cm-1 and 1635 cm-1)…

— Martins, I., Hartmann, D.O., Alves, P.C. et al. Elucidating how the saprophytic fungus Aspergillus nidulans uses the plant polyester suberin as carbon source. BMC Genomics 15, 613 (2014). https://doi.org/10.1186/1471-2164-15-613

1737 = C=O stretch (esters)

Wheat Roots

#> [1] "032" "053"

rice roots

#> [1] "047" "055" "079" "103"

soy roots

#> [1] "050" "062" "080" "094"